
//
//  HomeViewController.swift
//  HSDouyu
//
//  Created by kyle on 2017/7/27.
//  Copyright © 2017年 Hansong. All rights reserved.
//

import UIKit
private let kScreenW = UIScreen.main.bounds.width
private let kScreenH = UIScreen.main.bounds.height
private let kTitleViewH : CGFloat = 40

class HomeViewController: UIViewController {
    fileprivate lazy var pageTitleView: PageTitleView = {
        [weak self] in
        let titleFrame = CGRect(x: 0, y: 64, width: kScreenW, height: kTitleViewH)
        let titles = ["推荐", "游戏", "娱乐", "趣玩"]
        let titleView = PageTitleView(frame: titleFrame, titles: titles)
        titleView.delegate = self
        return titleView
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}
extension HomeViewController {
    fileprivate func setupUI() {
        automaticallyAdjustsScrollViewInsets = false

        //setupNavigationBar()
        view.addSubview(pageTitleView)

    }
    fileprivate func setupNavigationBar() {
        // 1.设置左侧的Item
        navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "logo")
        
        // 2.设置右侧的Item
        let size = CGSize(width: 40, height: 40)
        let historyItem = UIBarButtonItem(imageName: "image_my_history", highImageName: "Image_my_history_click", size: size)
        let searchItem = UIBarButtonItem(imageName: "btn_search", highImageName: "btn_search_clicked", size: size)
        let qrcodeItem = UIBarButtonItem(imageName: "Image_scan", highImageName: "Image_scan_click", size: size)
        navigationItem.rightBarButtonItems = [historyItem, searchItem, qrcodeItem]
    }

}
extension HomeViewController : PageTitleViewDelegate {
    func pageTitleView(_ titleView: PageTitleView, selectedIndex index: Int) {
       // pageContentView.setCurrentIndex(index)
    }
}
